package com.coinworld.Enum;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
 * @description
 * @author:
 * @create: 2020-02-25
 **/
@AllArgsConstructor
@NoArgsConstructor
public enum AnnualCardOrderEnum {

    BUY(0,"购买"),
    GIVE(1,"赠送");


    @Getter
    @Setter
    private Integer index;

    @Getter
    @Setter
    private String name;

    public static String getName(int index) {
        for (AnnualCardOrderEnum annualCardOrderEnum : AnnualCardOrderEnum.values()) {
            if (annualCardOrderEnum.index == index) {
                return annualCardOrderEnum.name;
            }
        }
        return null;
    }

    public static Integer getIndex(String name) {
        for (AnnualCardOrderEnum annualCardOrderEnum : AnnualCardOrderEnum.values()) {
            if (annualCardOrderEnum.name.equals(name)) {
                return annualCardOrderEnum.index;
            }
        }
        return null;
    }
}
